App({
  setStorageUser: function (key, params, callback) {
    wx.setStorage({
      key: key,
      data: params,
      success: function (res) {
        if (callback && typeof callback == 'function') {
          callback(res)
        }
      }
    });
  },
  getNewList: function () {
    let list = []
    let news = this.globalData.news
    for (var i = 0; i < news.length; i++) {
      let obj = {}
      obj.id = news[i].id
      obj.title = news[i].title
      obj.poster = news[i].poster
      obj.date = news[i].date
      obj.content = news[i].content
      list.push(obj)
    }
    return list
  },
  getNewsDetail: function (newsID) {
    let message = {
      code: '404',
      news: {}
    };
    console.log(this.globalData.news.length)
    for (var i = 0; i < this.globalData.news.length; i++) {
      if (newsID == this.globalData.news[i].id) {
        message.code = '200',
          message.news = this.globalData.news[i];
        break;
      }
    }
    return message;
  },
  globalData: {
    isLogin: false,
    news: [],
    userInfo: {
      nickName: '取个昵称吧',
      avatarUrl: '',
      userPhone:15011111111,
    }
  }
})